home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.761 < prev    next >
Text File  |  1992-02-06  |  2KB  |  65 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;}
  2. \paperw13040
  3. \paperh10800
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 initialize cell class TextFieldCell  NXBrowserCell  ButtonCell\
  8. \
  9.  
  10. \fi-420\li420 Q:  I have subclassed Button and ButtonCell in my application.  I am setting the cell class for my button in the 
  11. \b -init:
  12. \b0  method for my Button subclass like this:\
  13. \
  14.  
  15. \f1\fs24\fi20 @implementation MyButton : Button\
  16. \
  17. -init\
  18. \{\
  19.     [super init];\
  20.  
  21. \b     [MyButton  setCellClass: [MyButtonCell class]];\
  22.  
  23. \b0     return self;\
  24. \}\
  25. @end\
  26.  
  27. \f0\fs28\fi-420 \
  28.  
  29. \fi20 However my cell class is not being created and initialized properly.  What is going on?\
  30.  
  31. \fi0\li0 \
  32.  
  33. \fi-420\li420 A:  
  34. \b setCellClass:
  35. \b0  is a factory method and must occur prior to any instance creation—
  36. \b init:
  37. \b0  is too late.  The correct place to do this is in the 
  38. \b +initialize
  39. \b0  factory method for your Button subclass (which is called before any instances are created).  This problem can occur with all Cell subclasses—such as TextField and NXBrowser.   (
  40. \b +initialize
  41. \b0  is an Object factory method; see the Object class specification sheet for more information.) \
  42. \
  43.  
  44. \f1\fs24\fi20 @implementation MyButton : Button\
  45. \
  46. +initialize\
  47. \{\
  48.     [super initialize];\
  49.  
  50. \b     [MyButton  setCellClass: [MyButtonCell class]];\
  51.  
  52. \b0     return self;\
  53. \}\
  54. @end\
  55.  
  56. \f0\fs28\fi0\li0 \
  57.  
  58. \fc0 \
  59. \
  60. QA761\
  61. \
  62. Valid for 2.0\
  63. \
  64.  
  65.